import 'dart:io';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:home_box/pages/medicine/MedicineVM/medicine_add_vm.dart';
///药品图片
class AddPicture extends StatelessWidget {
  const AddPicture({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MedicineVM>(
      tag: 'MedicineVM',
      builder: (controller) {
        return GestureDetector(
          onTap: controller.takePicFromCamera,
          child: Container(
            padding: EdgeInsets.all(5),
            margin: EdgeInsets.only(top: 20),
            decoration: BoxDecoration(
              border: Border.all(
                color: Colors.grey,
                width: 1,
                style: BorderStyle.solid,
              ),
              borderRadius: BorderRadius.circular(10),
            ),
            width: 100,
            height: 100,
            child: Center(
              child: Image(
                image: FileImage(File(controller.takePic.value)),
                errorBuilder: (
                  BuildContext context,
                  Object error,
                  StackTrace? stackTrace,
                ) {
                  return Image.asset(
                    'images/medicine_add_pic.png',
                    fit: BoxFit.cover,
                    width: 30,
                    height: 30,
                  );
                },
                fit: BoxFit.cover,
                width: 100,
                height: 100,
              ),
            ),
          ),
        );
      },
    );
  }
}
